<template>
  <div class="swiper_wrapper">
    <swiper :options="swiperOptions" v-if="showSwiper">
      <swiper-slide v-for="item of list" :key="item.id"
        ><img class="swiper-img" :src="item.imgUrl" alt=""
      /></swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "HomeSwiper",
  props: {
    list: Array,
  },
  data() {
    return {
      swiperOptions: {
        autoplay: {
          disableOnInteraction: false,
          delay: 3000,
        },
        pagination: {
          el: ".swiper-pagination",
          dynamicBullets: true,
          dynamicMainBullets: 1,
        },
        loop: "true",
      },
    };
  },
  computed: {
    showSwiper() {
      return this.list.length;
    },
  },
};
</script>

<style lang="scss" scoped>
.swiper_wrapper {
  background: #eee;
  width: 100%;
  height: 0;
  overflow: hidden;
  padding-bottom: 38.4625%;
  .swiper-img {
    width: 100%;
  }
}
</style>
